using System.Collections.Generic;

namespace PDLib
{
    public class RandomFromStaticSet<T> where T : IProbabilisictSetElement<T>
    {
        protected List<T> _elements;

        public RandomFromStaticSet(params T[] elements)
        {
            _elements = new List<T>();
            _elements.AddRange(elements);
            NormalizeSet();
        }

        public void NormalizeSet()
        {
            double total = 0;
            foreach (T element in _elements)
            {
                //total += element.Distribution;
            }
            if (total != 1.0)
            {
                foreach (T element in _elements)
                {
                    //element.Distribution /= total;
                }
            }
        }

        public virtual object[] GetNext()
        {
            double max_prob = 0;
            T selection = default(T);
            foreach (T element in _elements)
            {
                T prob = element.Distribution.NextSample();
                //if (prob > max_prob)
                //{
                //    selection = element;
                //    max_prob = prob;
                //}
            }

            return null;
        }
    }
}